from selenium.webdriver.common.by import By

from 实战二.base.base_actions import BaseAction


class CalculatorPages(BaseAction):

    # 数字按钮, 需要进行格式化
    num_btn = By.ID, "simple{}"

    # 加法按钮
    add_btn = By.ID, "simpleAdd"

    # 等号按钮
    eql_btn = By.ID, "simpleEqual"

    # 计算后的结果
    result = By.ID, "resultIpt"

    # 点击数字
    def click_num_btn(self, num):
        self.find_ele_num(self.num_btn, num).click()

    # 点击加号
    def click_add_btn(self):
        self.click(self.add_btn)

    # 点击等号
    def click_eql_btn(self):
        self.click(self.eql_btn)

    # 获取结果
    def get_result(self):
        return self.find_e(self.result).get_attribute("value")